package com.study.juc;

import java.util.concurrent.TimeUnit;

public class SynchronizedDefect {

    public static void main(String[] args) throws InterruptedException {


        SynchronizedDefect synchronizedDefect = new SynchronizedDefect();
        Thread t1 = new Thread(synchronizedDefect::syncMethod);
        t1.start();

        
        TimeUnit.MILLISECONDS.sleep(1);
        Thread t2 = new Thread(synchronizedDefect::syncMethod);
        t2.start();
        TimeUnit.MILLISECONDS.sleep(1);
        t2.interrupt();
        System.out.println(t2.isInterrupted());
        
        System.out.println(t2.getState());
    }
    
    public synchronized  void syncMethod(){
        try {
            TimeUnit.HOURS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
